package com.kim.nidoya.activity;

import java.util.ArrayList;

import com.kim.nidoya.utils.ActivityDispatchUtil;

import android.app.ActivityGroup;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Toast;

@SuppressWarnings({ "deprecation", "unused" })
public class SettingsGroup extends BaseGroupActivity {
	protected static ActivityGroup group;
	private ArrayList<View> history;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		group = SettingsGroup.this;
		history = new ArrayList<View>();
	}

	@Override
	public void onBackPressed() {
		back();
		return;
	}

	@Override
	protected void onStart() {
		super.onStart();
		Intent intent = new Intent(this, SettingsActivity.class);
		Window w = group.getLocalActivityManager().startActivity(
				"SettingsActivity", intent);
		View view = w.getDecorView();

		replaceView(view);

		group.setContentView(view);
	}

	public void replaceView(View v) {
		history.add(v);
		setContentView(v);
	}

	public void back() {
		if (history.size() > 1) {
			history.remove(history.size() - 1);
			setContentView(history.get(history.size() - 1));
		} else {
			//finish();
			ActivityDispatchUtil.toHome(this);
		}
	}

}
